//
//  ViewController.m
//  afnleaks
//
//  Created by  Mac on 2021/3/31.
//

#import "ViewController.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tabView;
@property (nonatomic,strong) NSArray * dataArr;
@end


@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tabView.dataSource = self;
    self.tabView.delegate = self;
    self.dataArr = @[
        @{@"func":@"GET",@"ctl":@"GETViewCtl"},
        @{@"func":@"POST",@"ctl":@"POSTViewCtl"},
        @{@"func":@"Download",@"ctl":@"DownLoadCtl"},
        @{@"func":@"Upload",@"ctl":@"UPLoadViewCtl"},
        @{@"func":@"网络状态",@"ctl":@"NETSTATUSCtl"}
    ];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell * cell = [UITableViewCell new];
    NSDictionary * dic = self.dataArr[indexPath.row];
    cell.textLabel.text = dic[@"func"];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 70;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.dataArr.count;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary * dic = self.dataArr[indexPath.row];
    NSString * className = dic[@"ctl"];
    ViewController * vc = [[NSClassFromString(className) alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
    
}
@end

